package main

import (
	"fmt"
	"net/http"
	"strings"
)

func main() {
	//	r, e := http.Get("http://127.0.0.1:8021/myGo?GetPara1=1&GetPara2=2")
	// 法1
	/*r, e := http.Post(
	"http://127.0.0.1/smartrtb_test",
	"application/x-www-form-urlencoded",
	strings.NewReader("PostPara1=post1"))
	*/
	// 法2
	/*
		r, e := http.PostForm("http://127.0.0.1:8021/myGo?GetPara1=1&GetPara2=2",
			url.Values{"PostPara1": {"post1"}, "PostPara2": {"post2"}})
	*/

	content := ""

	for i := 0; i < 3; i++ {

		content = fmt.Sprintf("smartrtb_test, count: %d", i)

		r, e := http.Post(
			"http://127.0.0.1/smaato",
			"application/x-www-form-urlencoded",
			strings.NewReader(content))

		if e != nil {
			fmt.Println("err:", e)
		}
		defer r.Body.Close()
	}

	/*
		bytes := make([]byte, 1024)

		fmt.Println("网页内容为：")
		for {
			n, err := r.Body.Read(bytes)
			//	log.Println("n:", n)
			if n == 0 {
				fmt.Println()
				fmt.Println("====读取结束==== ")
				break
			} else if err != nil && err != io.EOF {
				fmt.Println("错误err:", err)
			}

			fmt.Print(string(bytes[:n]))
		}
	*/

}
